<template>
  <el-dropdown v-bind="$attrs">
    <span class="el-dropdown-link">
      <slot>
        <el-icon color="#409EFC" :size="20">
          <Grid />
        </el-icon>
      </slot>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          v-for="(item, index) in menu"
          :key="index"
          @click="handleDropDownClick(item)"
          >{{ item.name }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts">
import { Grid } from "@element-plus/icons-vue";
import { PropType } from "vue";
const emit = defineEmits(["click"]);
interface Menu {
    name:string,
    [propName: string]:any
}
defineProps({
  menu: {
    type: Array as PropType<Menu[]>,
    required: true,
  },
  placement: {
    type: String,
    default: "bottom",
  },
});
const handleDropDownClick = (e: Menu) => {
  emit("click", e);
};
</script>
